<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>施工单位审批</title>
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />

<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>

<script src="js/bootstrap2/js/bootstrap-table.js"></script>
<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script> 
<script type="text/javascript" src="js/sharefunction.js"></script> 
<script type="text/javascript" src="js/form.js"></script> 
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js" ></script>
<script type="text/javascript">
$(function(){
	//禁用表单和按钮
	hideButton();
	//悬浮提示
	toolTip();
	//修改字段标记记录变量
	<c:set var="marks" value="原数据"/>
	//附件赋值
	initRoadWorkFiles();
});
function hideButton(){
	//锁定表单
	$("#roadworkForm input").attr("readonly",true);
	$("#roadworkForm select").attr("disabled",true);
	//禁止点击上传按钮
	$("#roadworkForm div[id^='filePicker']").hide();
}

</script>
</head>
<!-- 施工单位审批 -->
<body>
<div>
	<!-- 表单开始 -->
	<form id="roadworkForm" method="post" >
		<input type="hidden" id="roadwork_articleId">
		<div class="panel panel-default">
			<div class="panel-body ">
				<table cellpadding="10" cellspacing="5" class="mytable">
					<tr>
						<td width="90"><span class="style_btn">施工方案</span></td>
						<td>
							<select id="roadwork_s2" style="width: 200px;" >
								<option value="${du.fkdschemeId}">${ds.schemeName}</option>
							</select>
							<c:if test="${not empty requestScope.map.schemeName }"><span class="toolTip mark-msg"data-tip="${requestScope.map.schemeName }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.schemeName=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						</td>
					</tr>
					<tr>
						<td width="90"><span class="style_btn">企业名称</span></td>
						<td><input name="unitName"  value="${du.unitName}" />
							<c:if test="${not empty requestScope.map.unitName }"><span class="toolTip mark-msg"data-tip="${requestScope.map.unitName }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.unitName=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">企业证件</span></td>
						<td><input name="unitCa" value="${du.unitCa}" />
							<c:if test="${not empty requestScope.map.unitCa }"><span class="toolTip mark-msg"data-tip="${requestScope.map.unitCa }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.unitCa=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						</td>
					</tr>
					<!-- 企业证件附件 -->
					<tr>
						<td></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_unitCa'></div> <!-- 上传按钮 -->
							<div id='filePicker_unitCa' style="display: none;">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">施工资质</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_workAptitude'></div> <!-- 上传按钮 -->
							<div id='filePicker_workAptitude' style="display: none;">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">授权委托</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_authorize'></div> <!-- 上传按钮 -->
							<div id='filePicker_authorize' style="display: none;">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">相关保险</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_insurance'></div> <!-- 上传按钮 -->
							<div id='filePicker_insurance' style="display: none;">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">人员清册</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_staffList'></div> <!-- 上传按钮 -->
							<div id='filePicker_staffList' style="display: none;">上传</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<input type="hidden" id="entityId_id" name="roadworkId" value="${requestScope.du.id }"/>
		<input type="hidden" id="apId" name="apId" value="${requestScope.apId }"/>
		<c:if test="${requestScope.notPassExamine}">
			<!-- 修改时添加变更说明 -->
			<div style="margin:10px;" id="approvalRemark">
				审批意见<textarea rows="3" name="approvalRemark"style="width:70%"></textarea><span style="color:red;">*</span>
			</div>
			<div style="width:100%;text-align:center; padding-top:0px">
				<button class="btn btn-danger radius my-btn"
					onclick="savaUnit(0)" type="button">同意</button>
				<button class="btn btn-default radius"
					onclick="savaUnit(1)" type="button">拒绝</button>
			</div>	
		</c:if>
	</form>
	<!-- 表单结束 -->
	<!-- 施工单位js -->
	<script type="text/javascript">
	function savaUnit(opt){
		var url = "customer/dm/disposeRoadWork";
		var apId = '${requestScope.apId }';
		var exDataId = '${exDataId}';
		var approvalRemark = $("textarea[name='approvalRemark']").val();
		var formData = {
				exDataId:exDataId,
	        	opt:opt,
	        	apId:apId,
	        	approvalRemark:approvalRemark
	    };
		disposeSave(opt,url,formData);
	}
		
	//添加图片
	function initRoadWorkFiles(){
		var roadworkId= $("#roadworkForm [name='roadworkId']").val();
		//获取原数据图片，为了去掉删除的图片片
		getFileListByFlag(roadworkId,"施工资质",2,"#list_workAptitude",setRoadRFL,imgPlus);
		getFileListByFlag(roadworkId,"企业证件",2,"#list_unitCa",setRoadRFL,imgPlus);
		getFileListByFlag(roadworkId,"授权委托",2,"#list_authorize",setRoadRFL,imgPlus);
		getFileListByFlag(roadworkId,"相关保险",2,"#list_insurance",setRoadRFL,imgPlus);
		getFileListByFlag(roadworkId,"人员清册",2,"#list_staffList",setRoadRFL,imgPlus);
		<c:if test="${requestScope.notPassExamine}"> 
		//编辑新加的图片数据
		var fileCas=${requestScope.caList};
		if(fileCas.length > 0){
			var workAptitude = "";//施工资质
			var unitCa = "";//企业证件
			var authorize = "";//授权委托
			var insurance = "";//相关保险
			var staffList = "";//人员清册
			for(var i=0;i<fileCas.length;i++){
				if(fileCas[i].articleId == "施工资质"){
					workAptitude += (","+fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "企业证件"){
					unitCa += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "授权委托"){
					authorize += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "相关保险"){
					insurance += (","+ fileCas[i].accessoryCAId);
				}else if(fileCas[i].articleId == "人员清册"){
					staffList += (","+ fileCas[i].accessoryCAId);
				}
			}
			if(workAptitude != ""){
				getFileTempList(workAptitude.substring(1),"#list_workAptitude", setRoadRFL, imgPlus);
			}
			if(unitCa != ""){
				getFileTempList(unitCa.substring(1), "#list_unitCa", setRoadRFL, imgPlus);
			}
			if(authorize != ""){
				getFileTempList(authorize.substring(1),"#list_authorize", setRoadRFL, imgPlus);
			}
			if(insurance != ""){
				getFileTempList(insurance.substring(1),"#list_insurance", setRoadRFL, imgPlus);
			}
			if(staffList != ""){
				getFileTempList(staffList.substring(1),"#list_staffList", setRoadRFL, imgPlus);
			}
		}
		</c:if>
	}
	
	//本页面图片放大通用方法,同时隐藏上传按钮与图片删除按钮
	function imgPlus(data){
		$.each(data,function(i,v){
			hideFileBtn(v.id);
			PostbirdImgGlass.init({
		    	domSelector:"#"+v.id+" img",
		    	animation:true,
		    	//height:'80%',
		    	myDocument:window.parent.parent.parent
			});
		});
	}
	//隐藏附件删除按钮
	function hideFileBtn(id){
		$("#"+id+" span.uploadcancel").hide();
	}
	//设置待删除附件的值到集合中
	function setRoadRFL(id,_this){
		layer.confirm('删除该图片？',{
			title:'警告',
			icon:0,
			shade:[0.1, '#fff']
		},function(){
			roadFuidList.push(id);
			//删除指定缩略图
			$("#"+id).remove();
			layer.close(layer.index);
		});
	}
	
	</script>
</div>
</body>
</html>